Set args = WScript.Arguments
If args.Count > 0 Then
	WScript.StdOut.WriteLine GetCommandLine(WScript.Arguments(0))
Else
    WScript.StdErr.WriteLine "Pid not found. Usage: GetCommandLine.vbs pid"
End If




Function GetCommandLine(dwProcessId)
 
    Set objWMIService = GetObject("WinMgmts:\\.\root\cimv2")
    Set objWin32PCollect = objWMIService.ExecQuery("select * from Win32_Process where Handle = " & dwProcessId)

    For Each objWin32Process in objWin32PCollect
	
        GetCommandLine = objWin32Process.CommandLine & Chr(10) & Chr(13)
 
    Next
 
End Function
